﻿@using System.Text;

@model EC_ASS.Models.BigModel

<div class="container">
    <div class="row">      
        <div class="span12">
            <div class="row">
                <div class="flexslider unstyled" data-plugin-options='{"directionNav":false, "animation":"slide", "slideshow": true, "maxVisibleItems": 6, "animationLoop": true}'>
                    <ul class="slides">
                        @foreach (var item in Model.Deals)
                        {
                            <li>
                                <div class="span2Hot portfolio-item thumbnail">
                                    <a href="/Deal/@item.DealResult.ID/@ToUrlName(item.DealResult.Name)/Info" class="thumb-info">
                                        <img alt="" src="@Url.Content("~/" + item.DealResult.Picture)"/>
                                        <span class="thumb-info-title">
                                            <span class="thumb-info-inner">Giảm giá @item.Discount%</span>
                                            <span class="thumb-info-type">@(item.DealResult.Price - ((item.DealResult.Price * item.Discount) / 100)) VNĐ</span>
                                        </span>
                                    </a>
                                    <span class="thumb-info-caption">
                                        <p class="alert alert-success countdown styled" id="@item.DealResult.ID">
                                            Thời gian KM @((item.ExpiredTime - DateTime.Now).Days) ngày.
                                        </p>
                                        <div id="option">
                                            <input type="submit" value="Mua" class="btn" />
                                            <input type="submit" value="Xem chi tiết" class="btn" />
                                        </div>
                                    </span>
                                </div>
                            </li>
                        }
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
@functions {
    string ToUrlName(string name)
    {
        string stFormD = name.Normalize(NormalizationForm.FormD);
        StringBuilder sb = new StringBuilder();
        for (int ich = 0; ich < stFormD.Length; ich++)
        {
            System.Globalization.UnicodeCategory uc = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
            if (uc != System.Globalization.UnicodeCategory.NonSpacingMark)
            {
                sb.Append(stFormD[ich]);
            }
        }
        sb = sb.Replace('Đ', 'D');
        sb = sb.Replace('đ', 'd');
        return (sb.ToString().Normalize(NormalizationForm.FormD).ToUpperInvariant().Trim().Replace(" ", "-"));
    }
}